
/*
 页面父类基础界面
 */
import 'package:xsdk_flutter/xsdk/framework/page/x_page_state.dart';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:xsdk_flutter/xsdk/operation/x_constant_temp.dart';
import 'package:xsdk_flutter/xsdk/utils/x_utils_flutter.dart';
import 'package:xsdk_flutter/xsdk/utils/x_utils_log.dart';

/*
欢迎界面
第三方:
https://pub.flutter-io.cn/packages/animated_splash_screen


 */
abstract class XPageWelcomeState extends XPageState{

  int milliseconds=1500;
  Timer? _timer;

  XPageWelcomeState({super.isKeepPageState=false,required this.milliseconds});

  @override
  void onCreate() {
    super.onCreate();

    //不适用美团收银机,商米T2,导致其无法滑出底部导航栏
    //XFlutterUtils.setSystemStatusBar(true);

    if(milliseconds<1500){
      milliseconds=1500;
    }

    //延迟跳转
    _timer??=Timer(Duration(milliseconds: milliseconds), (){
      goNextPage();
    });

  }

  @override
  void onStart() {
  }

  @override
  Widget getBodyWidget(BuildContext context) {

    //注意:获得屏幕尺寸 在onBuildWidget中初始化获取
    XTempData.screenWidth=XFlutterUtils.getScreen(context,isWidth: true);
    XTempData.screenHeight=XFlutterUtils.getScreen(context,isWidth: false);
    XTempData.statusBarHeight=XFlutterUtils.getStatusBarHeight(context);
    XLogUtils.printLog('---screenWidth=${XTempData.screenWidth},screenHeight=${XTempData.screenHeight},statusBarHeight=${XTempData.statusBarHeight}');

    return getWelcomeWidget();
  }


  @required
  Widget getWelcomeWidget();



  @override
  Future<void> updateData({int pageIndex = 1}) async {
  }


  @override
  void onDestroy() {
    super.onDestroy();
    _timer?.cancel();
    _timer=null;
  }

  //跳转新界面
  @required
  void goNextPage();

}